package com.warmlight.voicepacket.network;


import android.os.Build;

import com.warmlight.voicepacket.BuildConfig;
import com.warmlight.voicepacket.utils.SPUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by weiweijinpeng on 2018/6/26.
 */

public class MapComm {

    private static Map<String,Object> map;

    //递交默认参数
    private static final String SECRETA = "com.zzgele.qmzb";

    public MapComm(){
        map=new HashMap<>();
    }

    public void put(String key,String value){
        map.put(key,value);
    }

    public static Map<String, Object> getMap() {
        //添加公共参数
        map.put("device","111");
        map.put("token",getUniquePsuedoID());
        map.put("platform","android");
        map.put("auth_key", SPUtils.getLoginAuthKey());
        map.put("version", BuildConfig.VERSION_NAME);
        //递交参数
        return map;
    }

    public static String getUniquePsuedoID() {
        String serial = null;

        String m_szDevIDShort = "35" +
                Build.BOARD.length() % 10 + Build.BRAND.length() % 10 +

                Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 +

                Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 +

                Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 +

                Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 +

                Build.TAGS.length() % 10 + Build.TYPE.length() % 10 +

                Build.USER.length() % 10; //13 位

        try {
            serial = android.os.Build.class.getField("SERIAL").get(null).toString();
            //API>=9 使用serial号
            return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
        } catch (Exception exception) {
            //serial需要一个初始化
            serial = "serial"; // 随便一个初始化
        }
        //使用硬件信息拼凑出来的15位号码
        return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
    }
}
